| Server IP : 121.121.20.254 / Your IP : 216.73.216.133 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/LibreOffice/help/en-US/text/sbasic/shared/ |
Upload File : |
<!DOCTYPE html>
<html lang="en-US" dir="ltr">
<head>
<base href="../../../../">
<noscript><meta http-equiv="refresh" content="0; URL=../../../../en-US/noscript.html"></noscript>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>CBool Function</title>
<link rel="shortcut icon" href="media/navigation/favicon.ico">
<link type="text/css" href="normalize.css" rel="Stylesheet">
<link type="text/css" href="prism.css" rel="Stylesheet">
<link type="text/css" href="default.css" rel="Stylesheet">
<script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="en-US/langnames.js"></script><script type="text/javascript" src="flexsearch.debug.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
<header id="TopLeftHeader"><a class="symbol" href="en-US/text/shared/05/new_help.html"><div></div></a><a class="logo" href="en-US/text/shared/05/new_help.html"><p dir="auto">LibreOffice 24.2 Help</p></a><div class="dropdowns"><div class="modules">
<button type="button" data-a11y-toggle="modules-nav" id="modules" aria-haspopup="true" aria-expanded="false" aria-controls="modules-nav">Module</button><nav id="modules-nav" hidden=""></nav>
</div></div></header><aside class="leftside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1" dir="auto">Contents</label><div id="Contents" class="contents-treeview"></div></aside><div id="SearchFrame"><div id="Bookmarks">
<input id="search-bar" type="search" class="search" placeholder="Search in bookmarks for chosen module" dir="auto"><div class="nav-container" tabindex="0"><nav class="index" dir="auto"></nav></div>
</div></div>
<div id="DisplayArea" itemprop="softwareHelp" itemscope="true" itemtype="http://schema.org/SoftwareApplication">
<a name="cbool"></a>
<a name="bm_id3150616"></a>
<meta itemprop="keywords" content="CBool function">
<h1 id="hd_id3150616" dir="auto">
<a name="CBool_h1"></a>CBool Function</h1>
<p id="par_id3145136" class="paragraph" dir="auto">Converts an expression or a set of expressions into a boolean. An expression is composed of strings, numbers and operators. Comparison, logical or mathematical operators are allowed inside expressions.</p>
<div class="embedded">
<a name="functsyntax"></a>
<h3 id="hd_id061420171139089682" dir="auto">Syntax:</h3>
</div>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
CBool (expression As Variant) As Boolean
</code></pre></div>
<p id="par_id681638266349216" class="paragraph" dir="auto"><span class="literal">expression</span> can be a number or a set of combined expressions.</p>
<div class="embedded">
<a name="functvalue"></a>
<h3 id="hd_id061420171139087480" dir="auto">Return value:</h3>
</div>
<p id="par_id3155419" class="paragraph" dir="auto">Boolean</p>
<div class="embedded">
<a name="functparameters"></a>
<h3 id="hd_id061420171139084157" dir="auto">Parameters:</h3>
</div>
<p id="par_id791636986444058" class="paragraph" dir="auto"><span class="emph">expression</span>: A logical expression, a mathematical formula, a numeric expression or a set of expressions combined with operators. During expression evaluation <a target="_top" href="en-US/text/sbasic/shared/03060000.html">logical operators</a> take preceedence over <a target="_top" href="en-US/text/sbasic/shared/03110100.html">comparison operators</a>, which in turn take preceedence over <a target="_top" href="en-US/text/sbasic/shared/03070000.html">mathematical operators</a>.</p>
<p id="par_id1001638264728895" class="paragraph" dir="auto">The <span class="literal">expression</span> can be a number or mathematical formula. When equals to 0, <span class="literal">False</span> is returned, otherwise <span class="literal">True</span> is returned.</p>
<p id="par_id3149655" class="paragraph" dir="auto">Multiple expressions such as <span class="input" data-tooltip="Click on text to copy to clipboard">expr1 [[{operator] expr2]..]</span> can be combined. <span class="input" data-tooltip="Click on text to copy to clipboard">expr1</span> and <span class="input" data-tooltip="Click on text to copy to clipboard">expr2</span> can be any string or numeric expressions that you want to evaluate. <span class="literal">CBool</span> combines the expressions and returns either <span class="literal">True</span> or <span class="literal">False</span>. <span class="input" data-tooltip="Click on text to copy to clipboard">operator</span> can be a <a target="_top" href="en-US/text/sbasic/shared/03070000.html">mathematical operator</a>, <a target="_top" href="en-US/text/sbasic/shared/03060000.html">logical operator</a> or <a target="_top" href="en-US/text/sbasic/shared/03110100.html">comparison operator</a>.</p>
<div class="embedded">
<a name="errorcode"></a>
<h3 id="hd_id3152869" dir="auto">Error codes:</h3>
</div>
<div class="embedded"><p class="embedded" dir="auto">5 Invalid procedure call</p></div>
<div class="embedded">
<a name="functexample"></a>
<h3 id="hd_id061420171139088233" dir="auto">Example:</h3>
</div>
<p id="par_id3145171" class="paragraph" dir="auto">In the following examples, the <span class="literal">CBool</span> function evaluates a logical expression, a mathematical formula and the value that is returned by the <span class="literal">Instr</span> function. The function checks if the character "a" is found in the sentence that was entered by the user.</p>
<div class="bascode" itemscope="true" itemtype="http://schema.org/SoftwareSourceCode" itemprop="codeSampleType" content="snippet" data-tooltip="Click on text to copy to clipboard"><pre dir="auto"><code class="language-visual-basic line-numbers">
Sub ExampleCBool
Print CBool( 1>2 Xor 44 ) ' computes to True
Print CBool( expression := 15 /2 -7.5 ) ' displays False as expression equals 0
txt = InputBox("Please enter a short sentence:")
' Proof if the character "a" appears in the sentence.
' Instead of the command line
' If Instr(Input, "a")<>0 Then...
' the CBool function is applied as follows:
If CBool(Instr(txt, "a")) Then
MsgBox "The character »a« appears in the sentence you entered!"
EndIf
End Sub
</code></pre></div>
<a name="relatedtopics"></a><div class="relatedtopics">
<p class="related" itemprop="mentions" dir="auto"><a name="related"></a><span class="emph">Related Topics</span>
</p>
<div class="relatedbody" itemprop="mentions">
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03120105.html">CByte Function</a></p></div>
<div class="embedded"><p class="embedded" dir="auto"><a target="_top" href="en-US/text/sbasic/shared/03100050.html">CCur Function</a></p></div>
</div>
</div>
</div>
<div id="DonationFrame"></div>
<footer><div id="DEBUG" class="debug">
<h3 class="bug">Help content debug info:</h3>
<p dir="auto">This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/sbasic/shared/03100100.xhp" target="_blank">/text/sbasic/shared/03100100.xhp</a></p>
<p dir="auto">Title is: CBool Function</p>
<p id="bm_module" dir="auto"></p>
<p id="bm_system" dir="auto"></p>
<p id="bm_HID" dir="auto"></p>
</div></footer>
</body>
</html>